<div class='container'>
<?php $n = 0;?>
<?php foreach ($msg as $k => $v) {?>
<?php 
$n++;
if (strstr($v['sina_id'], '.')){$v['sina_id'] = strstr($v['sina_id'], '.', true);}
if (strstr($v['idstr'], '.')){$v['idstr'] = strstr($v['idstr'], '.', true);}
if (strstr($v['re_sina_id'], '.')){$v['re_sina_id'] = strstr($v['re_sina_id'], '.', true);}
if (strstr($v['re_idstr'], '.')){$v['re_idstr'] = strstr($v['re_idstr'], '.', true);}
?>
<div class='alert span8'>
	<div class='profile_image_url span1' >
		<img src='<?php echo $v["profile_image_url"]; ?>' width='50' height=50/>
		<p><?php echo $v['screen_name'];?></p>
	</div>
	<div class='text span6'>
		<p class='text'><?php echo $v['text']; ?></p>
		<?php if ($v['original_pic'] != '') {?>
		<br />
		<a class="miniImg artZoom" href="<?php echo $v['original_pic']; ?>" rel="<?php echo $v['original_pic']; ?>" target="_blank"><img src="<?php echo $v['original_pic']; ?>" width='80px'/></a>
		<?php }?>
	<?php if ($v['re_idstr']) {?>
	<div class='alert alert-error span6'>
		<p class='re_text'>
			<p><?php echo "<a class='re_screen_name' href='http://weibo.com/{$v['re_idstr']}' target='_blank'>{$v['re_screen_name']}:</a>&nbsp;";?><?php echo $v['re_text']; ?></p>
			<?php if ($v['re_original_pic'] != '') {?>
			<a class="miniImg artZoom" href="<?php echo $v['re_original_pic']; ?>" rel="<?php echo $v['re_original_pic']; ?>" target="_blank"><img src="<?php echo $v['re_original_pic']; ?>" width='80px'/></a>
			<?php }?>
		</p>
		<div class='span6 offset1 links'>
		<ul>
		<li><?php echo "{$v['re_created_at']}";?></li>
		<li><?php echo "<a href='javascript:void(0)'>转发({$v['re_reposts_count']})</a>";?></li>
		<li><?php echo "<a href='javascript:void(0)'>评论({$v['re_comments_count']})</a>";?></li>
		<li><?php echo "<a href='javascript:void(0)' data-user='{$v['re_screen_name']}' data-content='{$v['re_text']}' data-sina-id='{$v['re_sina_id']}' data-pic='{$v['re_original_pic']}' class='clone' >克隆</a>";?></li>
		<li><?php echo "<a target='_blank' href='http://api.t.sina.com.cn/{$v['re_idstr']}/statuses/{$v['re_sina_id']}'>永久链接</a>";?></li>
		</ul>
		</div>

	</div>
<?php } ?>
<div class='span6 offset2 links'>
<ul>
<li><?php echo "{$v['created_at']}";?></li>
<li><?php echo "<a href='javascript:void(0)' >转发({$v['reposts_count']})</a>";?></li>
<li><?php echo "<a href='javascript:void(0)'>评论({$v['comments_count']})</a>";?></li>
<li><?php echo "<a href='javascript:void(0)' data-user='{$v['screen_name']}' data-content='{$v['text']}' data-sina-id='{$v['sina_id']}' data-pic='{$v['original_pic']}' class='clone' >克隆</a>";?></li>
<li><?php echo "<a target='_blank' href='http://api.t.sina.com.cn/{$v['idstr']}/statuses/{$v['sina_id']}'>永久链接</a>";?></li>
</ul>
</div>
</div>
<div style='clear:both;'></div>
</div>
<?php } ?>
<div class='offset0 pull-left'>
<?php echo html_entity_decode($page_links, ENT_QUOTES, 'UTF-8'); ?>
</div>
</div>
<div class="modal fade hide" id="myModal" style="padding-right:8px;">
  <div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
    <h3>克隆微博</h3>
  </div>
  <div class="modal-body">
      <form class="form-horizontal" action='/queue/push' name='clone_push' id='clone_push'>
<div class="control-group">
<?php echo Form::textarea('description', '', array('rows' => 6, 'cols' => 20, 'class' => 'input-xxlarge')); ?>
</div>
<div class="control-group">
<?php $now = date('Y-m-d H:i', time() + 5*60 + 8*60*60);echo Form::input('post_time', $now, array('size' => 20, 'class' => 'input-large'));?>
</div>
<div class="alert alert-info">
选择上传则使用上传的图片代替原图片
</div>
<div class="control-group">
<?php echo Form::file('image',array('id' => 'image', 'class' => 'input-file'));?>
<input type='button' name='upload' class='btn' value='上传' onclick='ajaxFileUpload()'/>
</div>
<div class="control-group">
<select name='screen_name' id='screen_name'>
<?php foreach ($account as $k => $v) {?>
<option value='<?php echo $v['screen_name']; ?>'><?php echo $v['screen_name'];?></option>
<?}?>
</select>
</div>
<div class="control-group">
<?php echo Form::input('submit', '发送', array('id' => 'submit', 'type' => 'submit', 'class' => 'submit btn btn-success'));?>
</div>
      </form>
  </div>
</div>
<script>
var myModal = $('#myModal').html();
$('a.artZoom').artZoom();
$('.submit').button();
$('.clone').click(function() {
	$('#myModal').html(myModal);
$('input[name=post_time]').datetimepicker({
'dateFormat': 'yy-mm-dd'
});
	pic = $(this).attr('data-pic');
	$('#clone_msg').hide();
	var sina_id = $(this).attr('data-sina-id');
	$('#myModal textarea').html($(this).attr('data-content'));
	$('#myModal').modal('show');
	$('#image').val('');
	$('#clone_push').submit(function() {
		$('.submit').button('loading');
		var desc = $('textarea[name=description]').val();
		var post_time = $('input[name=post_time]').val();
		var screen_name = $('#screen_name').val();
		$.post('/queue/push_clone', {'screen_name': screen_name, 'image':pic, 'text': desc, 'post_time':post_time, 'sina_id':sina_id}, function(r) {
			if (r.msg == 'succ') {
				$('#clone_msg').html('操作成功');
			} else {
				$('#clone_msg').html('操作失败');
			}
			$('.submit').button('reset');
			alert('操作成功');
			//window.location.reload();
			//$('#clone_msg').fadeIn('slow');
		}, 'json');
		return false;
	});
});
$('input[name=post_time]').datetimepicker({
'dateFormat': 'yy-mm-dd'
});
function ajaxFileUpload() {
	$.ajaxFileUpload({
		url:'/queue/upload',
		secureuri:false,
		fileElementId:'image',
		dataType: 'json',
		beforeSend:function(){
			$("#loading").show();
		},
		complete:function() {
			$("#loading").hide();
			},				
		success: function (data, status) {
			if(typeof(data.msg) != 'undefined') {
				if(data.msg != 'succ') {
					alert('上传失败');
				} else {
					pic = data.path;
					alert('上传成功');
				}
			}
		},
		error: function (data, status, e) {
			       alert(e);
		}
	});
	return false;
}
</script>
<style>
.links li{
float:left;
list-style:none;
padding:5px;
}

.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
</style>
